﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HAMath
{

  public    class GetMinMaxDifference
    {

      /// <summary>
      /// 计算数据的最大最小值及其差值    出错（传入参数为null或者list的count为0）则返回 null
      /// </summary>
      /// <param name="value"></param>
      /// <returns></returns>
      public static MinMaxDiffResult GetValueStatistics(List <double  > value)
      {
          MinMaxDiffResult result = null;

          double min = double.MaxValue;
          double max = double.MinValue;

          if (value !=null && value .Count >0)
          {
              for (int i = 0; i < value .Count ; i++)
              {
                  if (value[i]<min )
                  {
                      min = value[i];
                  }
                  if (value [i]>max )
                  {
                      max = value[i];
                  }
              }
              result = new MinMaxDiffResult(min,max );

          }
          return result;
      }



    }
}
